<ion-header>
  <ion-toolbar class="orange-bar">
    <ion-buttons slot="start">
      <ion-button color="light" (click)="goBack()">
        <ion-icon name="ios-arrow-back"></ion-icon>
      </ion-button>
    </ion-buttons>
    <ion-title>快速注册</ion-title>
  </ion-toolbar>
</ion-header>

<ion-content>
  <form [formGroup]="formModel">
    <ion-radio-group formControlName="userType" text-center class="type-box" (ionChange)="typeChange($event)">
      <label>个人 <ion-radio [value]="1"></ion-radio></label>
      <label>企业 <ion-radio [value]="2"></ion-radio></label>
    </ion-radio-group>
    <ion-list>
      <ng-template [ngIf]="formModel.get('userType').value === 2">
        <ion-item>
          <ion-label>企业名称</ion-label>
          <ion-input formControlName="name" maxlength="255"></ion-input>
        </ion-item>
        <ion-item>
          <ion-label>企业规模</ion-label>
          <ion-select formControlName="enterpriseScale" interface="popover" placeholder="请选择">
            <ion-select-option *ngFor="let scale of enterpriseScaleOpts" [value]="scale['value']">{{scale['text']}}</ion-select-option>
          </ion-select>
        </ion-item>
        <ion-item>
          <ion-label>所属行业</ion-label>
          <ion-select formControlName="industry" interface="action-sheet" cancelText="取消" placeholder="请选择">
            <ion-select-option *ngFor="let industry of industryOpts" [value]="industry['value']">{{industry['text']}}</ion-select-option>
          </ion-select>
        </ion-item>
      </ng-template>
      <ion-item>
        <ion-label>手机号</ion-label>
        <ion-input formControlName="mobile" type="number" maxlength="11"></ion-input>
      </ion-item>
      <ion-item>
        <ion-label>验证码</ion-label>
        <ion-input formControlName="verificationCode" type="number" maxlength="6"></ion-input>
        <a *ngIf="resendTime === 0" slot="end" [class.disabled]="!formModel.get('mobile').valid" (click)="getVCode()">
          点击获取
        </a>
        <a *ngIf="resendTime !== 0" fill="clear" slot="end" class="disabled">
          重新获取({{resendTime}})
        </a>
      </ion-item>
      <ion-item>
        <ion-label>密&nbsp;&nbsp;&nbsp;码</ion-label>
        <ion-input formControlName="password" placeholder="由6~20位字母或数字组合" [type]="pwdObj.inputType" maxlength="20"></ion-input>
        <ion-icon slot="end" [name]="pwdObj.icon" [color]="pwdObj.color" (click)="showPassword()" style="z-index: 1"></ion-icon>
      </ion-item>
      <ion-item>
        <ion-label>邀请码</ion-label>
        <ion-input formControlName="invitationCode" placeholder="无邀请码可忽略" maxlength="255"></ion-input>
      </ion-item>
      <ion-item *ngIf="formModel.get('userType').value === 1">
        <ion-label>是否本机构员工</ion-label>
        <ion-toggle formControlName="employee"></ion-toggle>
      </ion-item>
    </ion-list>
  </form>

  <div padding>
    <ion-button expand="block" [disabled]="!formModel.valid" (click)="doRegistry()">同意协议并注册</ion-button>
    <p class="color-gray">点击注册即表示同意<a class="color-orange" (click)="openAgreement()">《盛融贷P2P互联网金融平台使用协议》</a></p>
  </div>

  <div padding text-center>
    <ion-button fill="outline" color="tertiary" (click)="goBack()">密码登录</ion-button>
  </div>
</ion-content>
